import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
import java.util.Stack;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 26727
 * Date: 2025-07-20
 * Time: 15:02
 */
public class Test72 {

    public static String decodeString(String s) {
        Stack<Integer> num = new Stack<>();
        Stack<StringBuilder> st = new Stack<>();
        char[] ch = s.toCharArray();
        int i = 0;
        st.push(new StringBuilder());
        int n = s.length();
        while (i < n) {
            if (ch[i] >= 'a' && ch[i] <= 'z') {
                StringBuilder tmp = new StringBuilder();
                while (i < n && ch[i] >= 'a' && ch[i] <= 'z') {
                    tmp.append(ch[i]);
                    i++;
                }
                st.peek().append(tmp);
            } else if (ch[i] >= '0' && ch[i] <= '9') {
                int tmp = 0;
                while (i < n && ch[i] >= '0' && ch[i] <= '9') {
                    tmp = tmp * 10 + (ch[i] - '0');
                    i++;
                }
                num.push(tmp);
            } else if (ch[i] == '[') {
                i++;
                while (i < n &&ch[i] >= 'a' && ch[i] <= 'z') {
                    StringBuilder tmp = new StringBuilder();
                    while (i < n && ch[i] >= 'a' && ch[i] <= 'z') {
                        tmp.append(ch[i]);
                        i++;
                    }
                    st.push(tmp);
                }
            } else {
                    int k = num.pop();
                    StringBuilder tmp = st.pop();
                    while (k != 0) {
                        st.peek().append(tmp);
                        k--;
                    }
                    i++;
                }
        }
        return st.peek().toString();
    }




    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String ret = decodeString(s);
        System.out.println(ret);
    }

}
